#include<stdio.h>
#include<string.h>
int main()
{
	while(1)
	{
		char a[20][100],temp=0;
		int flag=0,i=0,j=0,counter=0,max=0;
		while(1)
		{
			a[i][j]=getchar();
			counter++;
			if((a[i][j]<'A'||a[i][j]>'z'||(a[i][j]>'Z'&&a[i][j]<'a'))&&a[i][j]!=' '&&a[i][j]!='\n')
				flag=1;
			if(a[i][j]==' '||a[i][j]=='\n')
			{
				if(counter>max)
					max=counter;
				temp=a[i][j];
				a[i][j]='\0';
				i++;
				j=0;
				counter=0;
			}
			else
				j++;
			if(temp=='\n')
				break;
		}
		if(flag==1)
			printf("Input Error\n");
		if(strcmp("exit",a[0])==0&&i==1)
			break;
		max-=1;
		//printf("%d",i);
		for(int k=0;k<i;k++)
		{
			if(strlen(a[k])==max&&flag==0)
				printf("%s,",a[k]);
		}
		if(flag==0)
			printf("\n");
	}
	printf("End Of Input\n");
	return 0;
}
